/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

@Entity
public class EventTicket implements Serializable {
 
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String eventName;
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar purchaseDate;
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Calendar showDate;
    private String showVenue;
    private String seatNo;
    private boolean redeemed;
    private String stakeholderName;
    private String customerEmail;
    @ManyToOne(fetch=FetchType.EAGER)
    private Showing showing;

    public EventTicket() {
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventTicket)) {
            return false;
        }
        EventTicket other = (EventTicket) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.EventTicket[ id=" + id + " ]";
    }
    
    
    
    public String getShowDateinDateFormat(){
        Date showDate = this.showDate.getTime();
        java.text.DateFormat formatter = new java.text.SimpleDateFormat("EEE, MMM d, yyyy, hh:mm aaa");
        return formatter.format(showDate);
    }
    
    public String getPurchaseDateinDateFormat(){
        Date buyDate = this.purchaseDate.getTime();
        java.text.DateFormat formatter = new java.text.SimpleDateFormat("EEE, MMM d, yyyy, hh:mm aaa");
        return formatter.format(buyDate);
    }

    /**
     * @return the purchaseDate
     */
    public Calendar getPurchaseDate() {
        return purchaseDate;
    }

    /**
     * @param purchaseDate the purchaseDate to set
     */
    public void setPurchaseDate(Calendar purchaseDate) {
        this.purchaseDate = purchaseDate;
    }

    /**
     * @return the showVenue
     */
    public String getShowVenue() {
        return showVenue;
    }

    /**
     * @param showVenue the showVenue to set
     */
    public void setShowVenue(String showVenue) {
        this.showVenue = showVenue;
    }

    /**
     * @return the seatNo
     */
    public String getSeatNo() {
        return seatNo;
    }

    /**
     * @param seatNo the seatNo to set
     */
    public void setSeatNo(String seatNo) {
        this.seatNo = seatNo;
    }

    /**
     * @return the redeemed
     */
    public boolean isRedeemed() {
        return redeemed;
    }

    /**
     * @param redeemed the redeemed to set
     */
    public void setRedeemed(boolean redeemed) {
        this.redeemed = redeemed;
    }

    /**
     * @return the stakeholderName
     */
    public String getStakeholderName() {
        return stakeholderName;
    }

    /**
     * @param stakeholderName the stakeholderName to set
     */
    public void setStakeholderName(String stakeholderName) {
        this.stakeholderName = stakeholderName;
    }

    /**
     * @return the customerEmail
     */
    public String getCustomerEmail() {
        return customerEmail;
    }

    /**
     * @param customerEmail the customerEmail to set
     */
    public void setCustomerEmail(String customerEmail) {
        this.customerEmail = customerEmail;
    }

    /**
     * @return the showDate
     */
    public Calendar getShowDate() {
        return showDate;
    }

    /**
     * @param showTime the showDate to set
     */
    public void setShowDate(Calendar showDate) {
        this.showDate = showDate;
    }

    /**
     * @return the eventName
     */
    public String getEventName() {
        return eventName;
    }

    /**
     * @param eventName the eventName to set
     */
    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    /**
     * @return the show
     */
    public Showing getShowing() {
        return showing;
    }

    /**
     * @param show the show to set
     */
    public void setShowing(Showing showing) {
        this.showing = showing;
    }
}
